#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef unsigned long long Ull;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
string a,b;
void solve()
{
	cin>>a>>b;
	if(a.size()!=b.size())
	{
		cout<<-1<<endl;
		return; 
	}
	else
	{
		for(int i=0;i<a.size();i++)
		{
			cout<<int(a[i]-48)*int(b[i]-48);
		}
		cout<<endl;
		return;
	}
}
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		solve();
			
	}


	return 0;
}

